﻿using System.Collections.Generic;
using NTQOnlineExam.Services.DBCommand.Section;
using NTQOnlineExam.Services.Infrastructure;
using NTQOnlineExam.Services.Models;

namespace NTQOnlineExam.Services.ReportService.Section
{
    public class SectionReportService : ISectionReportService
    {
        private readonly ICommandExecutor _executor;

        public SectionReportService(ICommandExecutor executor)
        {
            _executor = executor;
        }

        public IList<SectionDTO> GetSections(int termId)
        {
            return _executor.Execute(new GetSectionByTermDbCommand(termId));
        }


        public IList<SectionDTO> GetSectionByTermList(IList<int> termIds)
        {
            return _executor.Execute(new GetSectionByTermListDbCommand(termIds));
        }

        public SearchResult<SectionDTO> SearchSections(SearchCriteria.SectionSearchCriteria searchCriteria, int pageSize, int pageIndex)
        {
            var result = _executor.Execute(new GetSectionDTOBySearchCriteriaDbCommand(searchCriteria, pageSize, pageIndex));
            return result;
        }

        public SectionDTO GetById(int sectionId)
        {
            return _executor.Execute(new GetSectionDTOByIdDbCommand(sectionId));
        }
    }
}
